import request from '@/utils/request'

const path = '/admin/system/sysRole'

export const FindByPage = (pageNum,pageSize,sysRoleDto)=>{
    return request({
        url: `${path}/findByPage/${pageNum}/${pageSize}`,  //模板字符串
        method: 'post',
        data: sysRoleDto   // 数据存放请求体   后端:@RequestBody
    })
}

export const Save = (data)=>{
    return request({
        url: `${path}/save`,  //模板字符串
        method: 'post',
        data
    })
}


export const GetById = (id)=>{
    return request({
        url: `${path}/getById/${id}`, 
        method: 'get'
    })
}


export const Update = (data)=>{
    return request({
        url: `${path}/update`,  //模板字符串
        method: 'put',
        data
    })
}


export const DeleteById = (id)=>{
    return request({
        url: `${path}/deleteById/${id}`, 
        method: 'delete'
    })
}


export const FindAllRoles = (userId)=>{
    return request({
        url: `${path}/findAllRoles/${userId}`,
        method: 'get'
    })
}

export const DoAssignRoleUser = (data)=>{
    return request({
        url: `/admin/system/userRole/doAssign`,
        method: 'put',
        data
    })
}


// 查询指定角色所对应的菜单id
export const GetSysRoleMenuIds = (roleId) => {
    return request({
        url: `/admin/system/sysRoleMenu/findSysRoleMenuByRoleId/${roleId}`,
        method: 'get'
    })
}


// 根据角色分配菜单请求方法
export const DoAssignMenuIdToSysRole = (assignMenuDto) => {
    return request({
        url: "/admin/system/sysRoleMenu/doAssign",
        method: 'put',
        data: assignMenuDto
    })
}